package de.hwr.chronix.client.alt;

import com.google.gwt.user.client.ui.Composite;




public class Formular_Abstimmung extends Composite {
	/*private final ChronixServiceAsync chronixService = GWT.create(ChronixService.class);
	private static Formular_AbstimmungUiBinder uiBinder = GWT
			.create(Formular_AbstimmungUiBinder.class);
	@UiField Label l_titel;
	@UiField Label l_titel_error;
	@UiField Label l_ort;
	@UiField TextBox t_titel;
	@UiField TextBox t_ort;
	@UiField Label l_ort_error;
	@UiField Label l_beschreibung;
	@UiField TextBox t_beschreibung;
	@UiField Label l_adminname;
	@UiField TextBox t_adminname;
	@UiField Label l_mail;
	@UiField TextBox t_mail;
	@UiField Label l_mail_error;
	@UiField Label l_adminname_error;
	@UiField Label l_beschreibung_error;
	@UiField DatePicker d_datepicker;
	@UiField FlexTable flext_dates;
	@UiField Button b_abstimmung_anlegen;
	@UiField Button b_auswaehlen;
	@UiField Label l_dauer;
	@UiField TextBox t_dauer;

	private ArrayList <String> datelist = new ArrayList<String>();
	
	interface Formular_AbstimmungUiBinder extends
			UiBinder<Widget, Formular_Abstimmung> {
	}

	public Formular_Abstimmung() {
		initWidget(uiBinder.createAndBindUi(this));
	}
	@UiHandler("b_abstimmung_anlegen")
	void onB_abstimmung_anlegenClick(ClickEvent event) {
		b_abstimmung_anlegen.setEnabled(false);
		
		PollDTO poll = new PollDTO("id_hash",t_adminname.getText(),t_titel.getText(),t_beschreibung.getText(),t_mail.getText(),t_ort.getText(),Short.parseShort(((TextBox) t_dauer).getText()),"admiID",null,null);
		chronixService.createPoll(poll, new AsyncCallback<String>() {
		
			@Override
			public void onSuccess(String result) {
				pollCreateSucsess(result);
			}
			
			@Override
			public void onFailure(Throwable caught) {
				Window.alert(caught.getMessage());
				
			}
		});
		
		
	}
	void pollCreateSucsess(String result){
		Chronix.clearPanel(this);
		Chronix.insertLinkpage(result);
	}
	@UiHandler("b_auswaehlen")
	void onB_auswaehlenClick(ClickEvent event) {
		int rowlines = flext_dates.getRowCount();
		@SuppressWarnings("deprecation")
		final String date = d_datepicker.getValue().toGMTString().substring(0, 11);

		if (datelist.contains(date))
	        return;

		datelist.add(date);
		flext_dates.setText(rowlines,0,date);
		
		Button removeDate = new Button("x");
	    removeDate.addClickHandler(new ClickHandler() {
	    public void onClick(ClickEvent event) {					
	        int removedIndex = datelist.indexOf(date);
	        datelist.remove(removedIndex);
	        flext_dates.removeRow(removedIndex);
	    }
	    });
	    flext_dates.setWidget(rowlines, 3, removeDate);
		
	
	}*/
}
